package com.kk.util.test.algorithm;

/**
 * @function: 常见排序算法
 * @author: kevin
 * @date: 2018-09-08 12:07
 */
public class PopOrder {
    private static int[] arr = {3,10,83,1,0,29};

    //冒泡排序
    public int[] pop(int[] ints) {
        for(int i=0; i<ints.length; i++) {
            for(int j=i+1; j<ints.length; j++) {
                if (ints[i] > ints[j]) {
                    ints[i] ^= ints[j];
                    ints[j] ^= ints[i];
                    ints[i] ^= ints[j];
                }
            }
        }
        return ints;
    }
    public static void main(String[] args){
        PopOrder test = new PopOrder();
        int[] arrs = new int[1000000];
        for (int i=0; i<1000000; i++) {
            arrs[i] = (int) (Math.random()*1000000);
        }
        long start = System.currentTimeMillis();
        System.out.println("开始执行冒泡算法"+start);
        int[] ints = test.pop(arrs);
        long end = System.currentTimeMillis();
        System.out.println("冒泡算法执行结束"+end+",耗时："+(end-start)+"ms");
//        for (int anInt : ints) {
//            System.out.print(anInt+ " ");
//        }
    }
}
